<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>定位层级</title>
  <style>
    *{
      padding: 0;
      margin: 0;
    }
    .container{
      background-color: skyblue;
      width: 400px;
      overflow: hidden;
      position: relative;
    }
    .item1{
      background-color: red;
      height: 100px;
      width: 100px;
      margin: 10px;
    }
    .item2{
      background-color: green;
      height: 100px;
      width: 100px;
      position: relative;
      top: -90px;
      left: 40px;
    }
    .item3{
      background-color: orange;
      height: 100px;
      width: 100px;
      position: absolute;
      top: 50px;
      left: 70px;
    }
    .item4{
      background-color: yellow;
      height: 100px;
      width: 100px;
      position: fixed;
      top: 80px;
      left: 100px;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="item1">1</div>
    <div class="item2">2</div>
    <div class="item3">3</div>
    <div class="item4">4</div>

  </div>
</body>
</html>